package com.dahong.cloud.authorize.config;

import com.lambda.cloud.websocket.WsSessionInfo;
import com.lambda.cloud.websocket.event.WsSubscribeEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.messaging.SessionSubscribeEvent;
import org.springframework.web.socket.messaging.SessionUnsubscribeEvent;

@Configuration
public class WebsocketConfig {

    @Bean
    public WsSubscribeEvent wsSubscribeEvent() {
        return new WsSubscribeEvent() {
            @Override
            public String[] topics() {
                return new String[] {"user"};
            }

            @Override
            public void subscribeEvent(WsSessionInfo<SessionSubscribeEvent> info) {
                System.out.println(info);
            }

            @Override
            public void unsubscribeEvent(WsSessionInfo<SessionUnsubscribeEvent> info) {
                System.out.println(info);
            }
        };
    }
}
